﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApp.App.Models.DAL.Cms
{
    public class Channel
    {
        public class __GetChannel_channels__:NRapid.Struct
		{
			public System.Int64 id;
			public System.Int64? type_id;
			public System.Int64? site_id;
			public System.String name;
			public System.String title;
			public System.Int64? sort_id;
			public System.String seo_folder;
			#region 写Json字符串
			public override void WriteJson(System.IO.TextWriter tw)
			{
				tw.Write("{");
						tw.Write("\"id\":");
						tw.Write(id.ToString());
						tw.Write(",");
						tw.Write("\"type_id\":");
						tw.Write(type_id==null?"null" : type_id.ToString());
						tw.Write(",");
						tw.Write("\"site_id\":");
						tw.Write(site_id==null?"null" : site_id.ToString());
						tw.Write(",");
						tw.Write("\"name\":");
						if(name==null)
						{
							tw.Write("null");
						}
						else
						{
							tw.Write("\"");
							tw.Write(name);
							tw.Write("\"");
						}
						tw.Write(",");
						tw.Write("\"title\":");
						if(title==null)
						{
							tw.Write("null");
						}
						else
						{
							tw.Write("\"");
							tw.Write(title);
							tw.Write("\"");
						}
						tw.Write(",");
						tw.Write("\"sort_id\":");
						tw.Write(sort_id==null?"null" : sort_id.ToString());
						tw.Write(",");
						tw.Write("\"seo_folder\":");
						if(seo_folder==null)
						{
							tw.Write("null");
						}
						else
						{
							tw.Write("\"");
							tw.Write(seo_folder);
							tw.Write("\"");
						}
				tw.Write("}");
			}
			#endregion
		}
		public NRapid.List<Models.Entity.Common.channel> GetChannel()
        {
            var con = new System.Data.SQLite.SQLiteConnection(NRapid.Config.ConfigurationManager.ConnectionStrings["Common"].ConnectionString);
			con.Open();
            #region	var channels;选取所有记录
			NRapid.List<Models.Entity.Common.channel> channels=new NRapid.List<Models.Entity.Common.channel>();
			var __GetChannel_channels_command__ = new System.Data.SQLite.SQLiteCommand("select * from channel", con);
			var __GetChannel_channels_reader__= __GetChannel_channels_command__.ExecuteReader();
			if (__GetChannel_channels_reader__.HasRows)
			{
				while (__GetChannel_channels_reader__.Read())
				{
					var __GetChannel_channels_temp__ = new Models.Entity.Common.channel();
					__GetChannel_channels_temp__.id = __GetChannel_channels_reader__.GetInt64(0);
					if(!__GetChannel_channels_reader__.IsDBNull(1)){__GetChannel_channels_temp__.type_id = __GetChannel_channels_reader__.GetInt64(1);}
					if(!__GetChannel_channels_reader__.IsDBNull(2)){__GetChannel_channels_temp__.site_id = __GetChannel_channels_reader__.GetInt64(2);}
					__GetChannel_channels_temp__.name =__GetChannel_channels_reader__.IsDBNull(3)?null: __GetChannel_channels_reader__.GetString(3);
					__GetChannel_channels_temp__.title =__GetChannel_channels_reader__.IsDBNull(4)?null: __GetChannel_channels_reader__.GetString(4);
					if(!__GetChannel_channels_reader__.IsDBNull(5)){__GetChannel_channels_temp__.sort_id = __GetChannel_channels_reader__.GetInt64(5);}
					__GetChannel_channels_temp__.seo_folder =__GetChannel_channels_reader__.IsDBNull(6)?null: __GetChannel_channels_reader__.GetString(6);
					channels.Add(__GetChannel_channels_temp__);
				}
			}
			__GetChannel_channels_reader__.Dispose();
			__GetChannel_channels_command__.Dispose();
			#endregion
			
            con.Close();
            return channels;
        }
    }
}